<!--
    -  Copyright (c) 2018-2025, haohanwork.com All rights reserved.
  -->
<template>
  <div class="execution">
    <basic-container>
      <h2 class="io-goods-detail">基础信息</h2>
      <template>
        <el-row class="io-goods-detail basic-information">
          <el-col :span="6">
            <div class="grid-content bg-purple">盘点单号:{{basicInformation.warehouseInventorySn}}</div>
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple-light">仓库:{{basicInformation.warehouseSn}}</div>
          </el-col>
          <!-- <el-col :span="6">
            <div class="grid-content bg-purple"></div>
            状态:{{basicInformation.purchaseType}}
          </el-col>-->
        </el-row>
        <el-row class="io-goods-detail basic-information">
          <el-col :span="6">
            <div class="grid-content bg-purple-light"></div>
            创建日期:{{basicInformation.createDate}}
          </el-col>
          <el-col :span="6">
            <div class="grid-content bg-purple-light">制单人:{{basicInformation.purchaseEmployee}}</div>
          </el-col>
        </el-row>
        <el-row class="io-goods-detail basic-information">
        </el-row>
      </template>
    </basic-container>
    <basic-container>
      <h2 class="io-goods-detail">详情</h2>
      <el-table :data="tableData" border show-summary style="width: 100%">
        <el-table-column prop="id" label="序号" type="index" width="100px"></el-table-column>
        <el-table-column prop="productName" label="商品">
        </el-table-column>
        <el-table-column prop="unit" sortable label="单位"></el-table-column>
        <el-table-column prop="originalNumber" sortable label="原有库存"></el-table-column>
        <el-table-column prop="resultNumber" label="实际库存">
        </el-table-column>
      </el-table>
    </basic-container>
  </div>
</template>
<!-- 采购退货 -->
<script>
import { mapGetters } from "vuex";
import {
  queryInventoryDetail
} from '@/api/scm/warehouse/warehouseinventory'
export default {
  name: "addpurchaseback",
  data() {
    return {
      tableData: [],
      otherMoney: 100,
      calcMoney: 1000,
      basicInformation: {
        purchaseOrderId: "POI10000",
        checkStatus: "待审核",
        purchaseType: "平台直购",
        supplierName: "浩瀚小店",
        deliveryTime: "2019-03-09",
        purchaseEmployee: "张**",
        makeBill: "运营"
      },
    };
  },
  computed: {
    ...mapGetters(["permissions"])
  },
  created(){
    this.init();
  },
  methods: {
    init() {
      let param = this.$route.query;
      this.basicInformation = this.$route.query;
      queryInventoryDetail(param).then(res =>{
        this.tableData = res.data.data.list;
      })
    },
    // 数据合计
    getSummaries(param){
      const { columns, data } = param;
      const sums = [];
      columns.forEach((column, index) => {
        if (index === 0) {
          sums[index] = '合计';
          return;
        }else if(index !== 3 && index !== 5 ){
          sums[index] = '';
          return;
        }
        const values = data.map(item => Number(item[column.property]));
        if (!values.every(value => isNaN(value))) {
          sums[index] = values.reduce((prev, curr) => {
            const value = Number(curr);
            if (!isNaN(value)) {
              return prev + curr;
            } else {
              return prev;
            }
          }, 0);
          sums[index] = sums[index].toFixed(2);
        } else {
          sums[index] = 'N/A';
        }
      });
      return sums;
    },
    backup: function() {
      this.$router.go(-1);
    }
  }
};
</script>

<style lang="scss" scoped>
.io-goods-detail {
  margin-bottom: 10px;
}
.settle-accounts {
  text-align: right;
}
.basic-information {
  margin-top: 20px;
  font-weight: inherit;
}
.return-btn {
  height: 100px;
  width: 100%;
  text-align: center;
  line-height: 100px;
}
</style>
